const http = require('http')

const server = http.createServer((request, response) => {
  // 设置响应状态码
  response.statusCode = 201
  // 设置相应状态描述
  response.statusMessage = 'success'
  // 设置响应头
  response.setHeader('content-Type', 'text/html;charset=utf-8')
  // 同时设置多个相同名称的响应头
  response.setHeader('test', [1, 2, 3, 4])
  // 设置响应体
  response.write('<h1>set response body</h1>')
  // 结束响应并设置响应体
  response.end('<h1>end</h1>')
})

server.listen(9000, () => {
  console.log(`
      _   _            _     
     | \\ | | ___   ___ | |  ___
     |  \\| |/ _ \\ / _ \\| |/ (_) \\
     | |\\  | (_) | (_) | | —————
     |_| \\_|\\___/ \\___/|_|\\ ____
    
    ✨ Node.js Server ✨ is up and running!
    Visit: http://localhost:9000
  `);
})